<template>
  <a-modal
    :title="'编辑下级用户 ' + username"
    :visible="visible"
    :confirm-loading="confirmLoading"
    @ok="handleOk"
    @cancel="visible = false"
  >
    <this-form ref="form" />
  </a-modal>
</template>
<script>
import thisForm from './form.vue'
export default {
  components: { thisForm },
  data() {
    return {
      visible: false,
      confirmLoading: false,
      username: '',
    }
  },
  methods: {
    open(row) {
      this.username = row.username
      this.visible = true
      this.confirmLoading = false
      this.$nextTick(() => {
        this.$refs.form.init(row)
      })
    },
    handleOk() {
      this.confirmLoading = true
      this.$refs.form.onSubmit(() => {
        this.visible = false
        this.confirmLoading = false
        this.$emit('refresh')
      })
    },
  },
}
</script>
